﻿{include file="public/header" /}
<form method="post">
    <div class="panel admin-panel">
        <div class="panel-head">
            <strong>{:lang('currency')['list']}</strong>
            <a style="float: right;" href="{:url('seller/index')}?page={:input('get.page')}"><< 返回</a>
        </div>
        <div class="padding border-bottom">
            <script>
                //city 参数和回调
                var uid = '{:input("get.uid")}';
                function select_uid() {
                    location.href="?uid="+uid;
                }
            </script>
            <input type="button" class="button button-small checkall" name="checkall" checkfor="id" value="{:lang('currency')['all_select']}"/>
            <a type="button" class="button button-small border-green" href="service/edit.html?uid={:input('get.uid')}"/>{:lang('currency')['add']}</a>
            <a id="select_del" type="button" class="button button-small border-red" href="#"/>{:lang('currency')['del']}</a>
            选择商户：{include file="public/seller" /}
            <a type="button" class="button button border-yellow search" href="#"/>标题{:lang('label')['search']}</a>
        </div>
        <table class="table table-hover">
            <tr>
                <th width="50">{:lang('label')['select']}</th>
                <th width="30">ID</th>
                <th width="100">{:lang('label')['seller']}</th>
                <td width="50">展示图</td>
                <th width="120">{:lang('label')['category']}</th>
                <th width="120">{:lang('label')['title']}</th>
                <th width="50">{:lang('label')['price']}</th>
                <th width="200">介绍</th>
                <!--<th width="100">{:lang('label')['flag']}</th>-->
                <th width="100">商品类型</th>
                <th width="100">{:lang('label')['status']}</th>
                <th width="100">{:lang('label')['handle']}</th>
            </tr>
            {volist name="data" id="service"}
            <tr>
                <td style="line-height:40px">
                    <input type="checkbox" name="id" value="{$service.id}"/>
                </td>
                <td style="line-height:40px">{$service.id}</td>
                <td style="line-height:40px">{:get_name($service.uid)}</td>
                <td style="line-height:40px"><img src="{$service.image1}" width="40" height="40"/></td>
                <td style="line-height:40px">{:get_catname($service.cate_id)}</td>
                <td style="line-height:40px">{$service.title}</td>
                <td style="line-height:40px">{$service.price}</td>
                <td style="line-height:40px">{$service.service}</td>
                <td style="line-height:40px">{if $service.type == "0"}商品外卖{else}上门服务{/if}</td>
                <td style="line-height:40px">{if $service.status == 0}<span class="icon-times text-dot">下架</span>{elseif $service.status == 1}<span class="icon-check text-sub">上架</span>{/if}</td>
                <td style="line-height:40px">
                    <a class="button border-blue button-little" href="__URL__/edit.html?id={$service.id}">{:lang('currency')['edit']}</a>
                    <a class="button border-red button-little" href="__URL__/del.html?id={$service.id}&page={:input('get.page')}" onclick="if(confirm('{:lang('currency')['del']}?')){return true;}return false;">{:lang('currency')['del']}</a>
                </td>
            </tr>
            {/volist}
        </table>
        {include file="public/pages" /}
    </div>
</form>
<script>
    layer.config({
        extend: 'extend/layer.ext.js'
    });
    $('#select_del').click(function () {
        var str = "";
        $("input:checkbox[name=id]:checked").each(function () {
            str += $(this).val() + ",";
        });
        if (str != '') {
            if (confirm("{:lang('currency')['del']}?"))
            {
                location.href = '{$Request.controller}/del.html?id=' + str;
            }
        }
    });
    $('.flag').click(function () {
        var id = $(this).attr("data-id");
        var oflag = $(this).attr("data-flag");
        var oflagtime = $(this).attr("data-flagtime");
        layer.open({
            title: "{:lang('label')['flag']}",
            content: "<div>{:lang('label')['flag']}: <select id='flag'><option value='0'>{:lang('label')['flag_0']}</option><option value='1'>{:lang('label')['flag_1']}</option><option value='2'>{:lang('label')['flag_2']}</option><option value='3'>{:lang('label')['flag_3']}</option><option value='4'>{:lang('label')['flag_4']}</option></select></div><br/><div>{:lang('label')['time']}: <input id='flagtime' type='date' value='" + oflagtime + "'/></div>",
            yes: function (layero, index) {
                var flag = $("#flag").val();
                var flagtime = $("#flagtime").val();
                if (flag == oflag && flagtime == oflagtime) {
                    layer.close(layero);
                } else {
                    if (flag > 0 && !flagtime) {
                        alert("{:lang('label')['time']}{:lang('currency')['required']}");
                    } else {
                        if (flag <= 0) {
                            flagtime = "";
                        }
                        $.get("{:url('admin/service/flag')}?id=" + id + "&flag=" + flag + "&flagtime=" + flagtime, function (data) {
                            layer.msg(data.msg);
                            if (data.code == "success") {
                                location.reload();
                            }
                        });
                    }
                }
            },
            success: function (layero, index) {
                $("#flag").find("option[value='" + oflag + "']").attr("selected", true);
            }
        });
    });
    $('.search').click(function () {
        layer.prompt({title: '{:lang('label')['service']}{:lang('label')['search']}'}, function (val) {
            location.href = "{:url('/admin/service')}?title=" + val;
        });
    });
</script>
{include file="public/footer" /}